package com.itheima.vo;


import com.itheima.domain.db.UserInfo;
import com.itheima.domain.mongo.TaoHua;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaohuaVo {

    private Long userId;
    private String avatar; //头像
    private String nickname; //昵称

    private Integer id;
    private String soundUrl; //语音url
    private String gender;//性别
    private Integer age;//年龄
    private Integer remainingTimes;//剩余次数




    public static TaohuaVo init(UserInfo userInfo, TaoHua item) {
        TaohuaVo vo = new TaohuaVo();
        if (userInfo!=null){
            //copy用户属性
            BeanUtils.copyProperties(userInfo, vo);
        }
        if (item!=null){
            //copy语音属性
            BeanUtils.copyProperties(item, vo);
            vo.setSoundUrl(item.getSoundUrl());
            vo.setId(userInfo.getId().intValue());
        }
        return vo;
    }
}
